﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web;

namespace $safeprojectname$
{
    /// <summary>publishing extensions</summary>
    public static class PublishingExtensions
    {
        #region ContainsError
        /// <summary>
        ///     Determines whether [contains any error] [the specified repository].
        /// </summary>
        /// <param name = "repository">The repository.</param>
        /// <returns>
        ///     <c>true</c> if [contains any error] [the specified repository]; otherwise, <c>false</c>.
        /// </returns>
        public static bool ContainsError(this IList<Message> repository)
        {
            if (repository.IsEmpty())
            {
                return false;
            }
            return repository.Any(msg => msg.Severity == Severity.Error);
        }
        #endregion ContainsError

        #region Publishing Reporter
        public static void PublishFatal(this IPublishingReporter reporter, string message, Exception exception)
        {
            PublishingManager.Publish(reporter, message, exception);
        }
        public static void PublishFatal(this IPublishingReporter reporter, Exception exception)
        {
            PublishingManager.Publish(reporter, null, exception);
        }
        public static void PublishDebug(this IPublishingReporter reporter, string subjectToPublish, params object[] args)
        {
            PublishingManager.Publish(reporter, Severity.Debug, subjectToPublish, args);
        }
        public static void PublishDebug(this IPublishingReporter reporter, Func<string> message)
        {
            PublishingManager.Publish(reporter, message, Severity.Debug);
        }
        public static void PublishInfo(this IPublishingReporter reporter, string subjectToPublish, params object[] args)
        {
            PublishingManager.Publish(reporter, Severity.Info, subjectToPublish, args);
        }
        public static void PublishInfo(this IPublishingReporter reporter, Func<string> message)
        {
            PublishingManager.Publish(reporter, message, Severity.Info);
        }
        public static void PublishWarning(this IPublishingReporter reporter, string subjectToPublish, params object[] args)
        {
            PublishingManager.Publish(reporter, Severity.Warning, subjectToPublish, args);
        }
        public static void PublishWarning(this IPublishingReporter reporter, Func<string> message)
        {
            PublishingManager.Publish(reporter, message, Severity.Warning);
        }
        public static void PublishError(this IPublishingReporter reporter, string subjectToPublish, params object[] args)
        {
            PublishingManager.Publish(reporter, Severity.Error, subjectToPublish, args);
        }
        public static void PublishError(this IPublishingReporter reporter, Func<string> message)
        {
            PublishingManager.Publish(reporter, message, Severity.Error);
        }
        #endregion Publishing Reporter
    }
}
